//
//  CMBankCenterCtrl.m
//  CreditManger
//
//  Created by sky on 15/11/2.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "CMBankCenterCtrl.h"
#import "CMMyCreReportCtrl.h"

@interface CMBankCenterCtrl ()<UITextFieldDelegate>
{
    UILabel *_name;
    UILabel *_idcard;
    UITextField *_idpass;
}

@end

@implementation CMBankCenterCtrl

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)buildLayout{
    self.title = @"征信中心";
    [self addTap];
    
    UIView *bgview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
    bgview.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bgview];
    [self makeLinewithRect:CGRectMake(0, 39.5, SCREEN_WIDTH, .5) Color:[LCCommon getColor:@"cccccc"] addview:bgview];
    
    NSString *str = @"232721********1113";
    CGSize strsize = [str sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}];
    _idcard = [self LabelWithRect: CGRectMake(SCREEN_WIDTH/2 - strsize.width/2, 0, strsize.width, 40) textColor:[LCCommon getColor:@"333333"] textstr:str textfont:13 textstyle:NSTextAlignmentCenter];
    [bgview addSubview:_idcard];
    
    _name = [self LabelWithRect:CGRectMake(10, 0,SCREEN_WIDTH - _idcard.origin.x - 10  , 40) textColor:[LCCommon getColor:@"333333"] textstr:@"郭阳" textfont:13 textstyle:NSTextAlignmentLeft];
    [bgview addSubview:_name];
    
    /**
     *  两种状态
     */
    
//    UIImage *huoqu = [UIImage imageNamed:@"huoqubaogao"];
//    UIImageView *hqview = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 - huoqu.size.width/2, 40 + 45, huoqu.size.width, huoqu.size.height)];
//    hqview.image = huoqu;
//    [self.view addSubview:hqview];
//    
//    UILabel *pro = [self LabelWithRect:CGRectMake(25, hqview.origin.y + huoqu.size.height + 20 , SCREEN_WIDTH - 50, 12) textColor:[LCCommon getColor:@"333333"] textstr:@"您还没信用报告,通过答题获取第一份信用报告吧~" textfont:10 textstyle:NSTextAlignmentCenter];
//    [self.view addSubview:pro];
//    
//    UIButton *anwer = [[UIButton alloc]initWithFrame:CGRectMake(25, pro.origin.y + 12 + 15, SCREEN_WIDTH - 50, 40)];
//    anwer.backgroundColor = [LCCommon getColor:HIGH_COLOR];
//    [anwer setTitle:@"开始答题" forState:UIControlStateNormal];
//    anwer.layer.cornerRadius = 2.5;
//    anwer.titleLabel.font = [UIFont systemFontOfSize:14];
//    [anwer addTarget:self action:@selector(foranwerpress) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:anwer];
    UIView *blowview = [[UIView alloc]initWithFrame:CGRectMake(0, 40 + 10, SCREEN_WIDTH , self.view.height - 40 - 10)];
    blowview.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:blowview];
    [self makeLinewithRect:CGRectMake(0, 0, SCREEN_WIDTH, .5) Color:[LCCommon getColor:@"cccccc"] addview:blowview];
    
    UILabel *tishi = [self LabelWithRect:CGRectMake(10, 20, SCREEN_WIDTH - 10, 12) textColor:[LCCommon getColor:@"333333"] textstr:@"输入您的身份验证码,以获取信用报告!" textfont:12 textstyle:NSTextAlignmentLeft];
    [blowview addSubview:tishi];
    
    _idpass = [self TextFieldWithRect:CGRectMake(10, tishi.origin.y + 12 + 8, SCREEN_WIDTH - 20, 35) leftImage:nil placeHold:@"输入身份验证码" index:0];
    _idpass.layer.borderColor = [LCCommon getColor:@"cccccc"].CGColor;
    _idpass.layer.borderWidth = .5;
    [blowview addSubview:_idpass];
    
    UIButton *gainbtn = [[UIButton alloc]initWithFrame:CGRectMake(10,_idpass.origin.y + 35 + 15, SCREEN_WIDTH - 20, 40)];
    gainbtn.backgroundColor = [LCCommon getColor:HIGH_COLOR];
    [gainbtn setTitle:@"获取报告" forState:UIControlStateNormal];
    [gainbtn setTitleColor:[UIColor colorWithWhite:1.0 alpha:0.2] forState:UIControlStateNormal];
    gainbtn.titleLabel.font = [UIFont systemFontOfSize:15];
    gainbtn.layer.cornerRadius = 2.5;
    [gainbtn addTarget:self action:@selector(gainpress) forControlEvents:UIControlEventTouchUpInside];
    [blowview addSubview:gainbtn];
    
    UILabel *againlbl = [self LabelWithRect:CGRectMake(SCREEN_WIDTH - 10 - 40, gainbtn.origin.y + 40 + 10, 40, 10) textColor:[LCCommon getColor:HIGH_COLOR] textstr:@"重新答题" textfont:10 textstyle:NSTextAlignmentRight];
    againlbl.userInteractionEnabled = YES;
    [blowview addSubview:againlbl];
    UITapGestureRecognizer  *agatap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(agatap)];
    [againlbl addGestureRecognizer:agatap];
}

#pragma mark - agatap

-(void)agatap{
    LLog(@"agatap");
}


#pragma mark - gainpress

-(void)gainpress{
    LLog(@"gainpress");
    CMMyCreReportCtrl *myrep = [[CMMyCreReportCtrl alloc]init];
    [self.navigationController pushViewController:myrep animated:YES];
}


#pragma mark - foranwerpress

-(void)foranwerpress{
    LLog(@"foranwerpress");
}

#pragma mark - MakeText

-(UITextField *)TextFieldWithRect:(CGRect)rect leftImage:(UIImage *)image placeHold:(NSString *)placeHold index:(NSInteger)index
{
    UITextField *text = [[UITextField alloc] initWithFrame:rect];
    text.placeholder = placeHold;
    text.backgroundColor = [UIColor clearColor];
    text.delegate = self;
    text.clearButtonMode = YES;
    text.textColor = [LCCommon getColor:@"333333"];
    text.font = [UIFont systemFontOfSize:12];
    [text setFont:[UIFont systemFontOfSize:12]];
    [text setValue:[LCCommon getColor:@"cccccc"] forKeyPath:@"_placeholderLabel.textColor"];
    
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 9, rect.size.height)];
    view.backgroundColor = [UIColor clearColor];
//    CGFloat width = image.size.width;
//    
//    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, (view.height - width)/2, width, width)];
//    
//    if (index == 0) {
//        imageView.frame = CGRectMake(0, view.height - 10 - width, width, width);
//    }
//    //    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(text.origin.x, text.origin.y + text.size.height + .5, text.size.width, .5)];
//    //    line.backgroundColor = [LCCommon getColor:@"cccccc"];
//    //    [_bgview addSubview:line];
//    
//    imageView.image = image;
//    [view addSubview:imageView];
    text.leftView = view;
    text.leftViewMode = UITextFieldViewModeAlways;
//    view = nil;
//    imageView = nil;
    
    return text;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)doTouch:(UIGestureRecognizer *)sender{
    [self.view endEditing:YES];
}


-(UILabel *)LabelWithRect:(CGRect)rect textColor:(UIColor *)color textstr:(NSString *)str textfont:(int)font textstyle:(NSTextAlignment)aligment{
    UILabel *label = [[UILabel alloc] initWithFrame:rect];
    label.textColor = color;
    label.text = str;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = aligment;
    label.numberOfLines = 0;
    return label;
}



-(void)makeLinewithRect:(CGRect)rect Color:(UIColor *)color addview:(UIView *)vi{
    UIView *line = [[UIView alloc]initWithFrame:rect];
    line.backgroundColor = color;
    [vi addSubview:line];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
